//
//  BKClasssifyLeftTableViewCell.m
//  bestkeep
//
//  Created by utouu_mhm on 16/11/7.
//  Copyright © 2016年 utouu. All rights reserved.
//

#import "BKClasssifyLeftTableViewCell.h"
#import "Masonry.h"

#define UIBackColor(r,g,b) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:1]
#define FontSize [UIFont systemFontOfSize:15]

@interface BKClasssifyLeftTableViewCell ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIView *lineView;

@end

@implementation BKClasssifyLeftTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.backgroundColor = [UIColor clearColor];
        [self createUI];
    }

    return self;
}

#pragma mark - UI
-(void)createUI{
    
    _titleLabel = [[UILabel alloc]init];
    _titleLabel.font = FontSize;
    _titleLabel.textAlignment = NSTextAlignmentCenter;
    _titleLabel.layer.cornerRadius = 10;
    _titleLabel.layer.masksToBounds = YES;
    [_titleLabel sizeToFit];
    [self addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self);
        make.height.equalTo(@20);
        make.width.equalTo(@72);
    }];
    
    _lineView = [[UIView alloc]init];
    _lineView.backgroundColor = UIBackColor(218, 218, 218); //=#DADADA
    [self addSubview:_lineView];

    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.mas_left);
        make.right.equalTo(self.mas_right);
        make.bottom.equalTo (self.mas_bottom);
        make.height.equalTo(@0.5);
    }];
}

-(void)setHasBeenSelected:(BOOL)hasBeenSelected{
    _isSeleted = hasBeenSelected;
    if (_isSeleted) {
        self.titleLabel.textColor = [UIColor whiteColor];
        self.titleLabel.backgroundColor = UIBackColor(0, 186, 156);
    }else{
        self.titleLabel.textColor = UIBackColor(64, 64, 64);//=#404040
        self.titleLabel.backgroundColor = [UIColor whiteColor];
    }
}

-(void)setClassifyLeftModel:(FirstChildrenList *)classifyLeftModel{
    _classifyLeftModel = classifyLeftModel;
    _titleLabel.text = _classifyLeftModel.name;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
